package com.xclink.app.service.core.ReplyMessage;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.xclink.app.utils.message.MessageUtil;
import com.xclink.app.utils.message.resp.Article;
import com.xclink.app.utils.message.resp.NewsMessage;

/**
 * 集中处理图文消息之回复图文消息
 * @author ljp
 *
 */
public class ProcessNewsMessage {

	public String process(String content,String toUserName,String fromUserName){
		 // 创建图文消息  
		NewsMessage newsMessage = new NewsMessage();
		 newsMessage.setToUserName(fromUserName);  
         newsMessage.setFromUserName(toUserName);  
         newsMessage.setCreateTime(new Date().getTime());  
         newsMessage.setMsgType(MessageUtil.RESP_MESSAGE_TYPE_NEWS);  
         newsMessage.setFuncFlag(0); 
         List<Article> articleList = new ArrayList<Article>();
         // 单图文消息  
         if ("1".equals(content)) {  
             Article article = new Article();  
             article.setTitle("微信公众帐号");  
             article.setDescription("来关注我的测试号啊");  
             article.setPicUrl("http://mmbiz.qpic.cn/mmbiz_jpg/0JZSNatOTJOspQGfr1GM3icrURyfTXgYmreZm62ziaUZmpa1fgicXq4PZty1A7STWNfib9JR5jZP6FlfX2PYeeh29g/0");  
             article.setUrl("http://www.baidu.com");  
             articleList.add(article);  
             // 设置图文消息个数  
             newsMessage.setArticleCount(articleList.size());  
             // 设置图文消息包含的图文集合  
             newsMessage.setArticles(articleList);  
             // 将图文消息对象转换成xml字符串  
            return  MessageUtil.MessageToXml(newsMessage);  
         } 
         // 单图文消息不含图片  
         else if ("2".equals(content)) {  
             Article article = new Article();  
             article.setTitle("你要的这里都有");  
             // 图文消息中可以使用QQ表情、符号表情  
             article.setDescription("玩法升级");  
             // 将图片置为空  
             article.setPicUrl("");  
             article.setUrl("http://www.baidu.com");  
             articleList.add(article);  
             newsMessage.setArticleCount(articleList.size());  
             newsMessage.setArticles(articleList);  
             return MessageUtil.MessageToXml(newsMessage);  
         }  
         // 多图文消息  
         else if ("3".equals(content)) {  
             Article article1 = new Article();  
             article1.setTitle("百度一下，你就知道\n引言");  
             article1.setDescription("");  
             article1.setPicUrl("http://mmbiz.qpic.cn/mmbiz_jpg/0JZSNatOTJOspQGfr1GM3icrURyfTXgYmreZm62ziaUZmpa1fgicXq4PZty1A7STWNfib9JR5jZP6FlfX2PYeeh29g/0");  
             article1.setUrl("http://www.baidu.com");  

             Article article2 = new Article();  
             article2.setTitle("第2篇\n老玩百度没意思");  
             article2.setDescription("");  
             article2.setPicUrl("");  
             article2.setUrl("http://www.baidu.com"); 

             Article article3 = new Article();  
             article3.setTitle("第3篇\n还是玩百度把");  
             article3.setDescription("");  
             article3.setPicUrl("");  
             article3.setUrl("http://www.baidu.com");  

             articleList.add(article1);  
             articleList.add(article2);  
             articleList.add(article3);  
             newsMessage.setArticleCount(articleList.size());  
             newsMessage.setArticles(articleList);  
             return MessageUtil.MessageToXml(newsMessage);  
         }  
         // 多图文消息首条消息不含图片  
         else if ("4".equals(content)) {  
             Article article1 = new Article();  
             article1.setTitle("没办法的事");  
             article1.setDescription("");  
             // 将图片置为空  
             article1.setPicUrl("");  
             article1.setUrl("http://www.baidu.com");  

             Article article2 = new Article();  
             article2.setTitle("第4篇\n迫不得已，只能...");  
             article2.setDescription("");  
             article2.setPicUrl("");  
             article2.setUrl("http://www.baidu.com");  

             Article article3 = new Article();  
             article3.setTitle("第5篇\n各种消息的接收与响应");  
             article3.setDescription("");  
             article3.setPicUrl("http://avatar.csdn.net/1/4/A/1_lyq8479.jpg");  
             article3.setUrl("http://blog.csdn.net/lyq8479/article/details/8952173");  

             Article article4 = new Article();  
             article4.setTitle("第6篇\n文本消息的内容长度限制揭秘");  
             article4.setDescription("");  
             article4.setPicUrl("http://avatar.csdn.net/1/4/A/1_lyq8479.jpg");  
             article4.setUrl("http://blog.csdn.net/lyq8479/article/details/8967824");  

             articleList.add(article1);  
             articleList.add(article2);  
             articleList.add(article3);  
             articleList.add(article4);  
             newsMessage.setArticleCount(articleList.size());  
             newsMessage.setArticles(articleList);  
             return MessageUtil.MessageToXml(newsMessage);  
         } 
      // 多图文消息最后一条消息不含图片  
         else if ("5".equals(content)) {  
             Article article1 = new Article();  
             article1.setTitle("第7篇\n文本消息中换行符的使用");  
             article1.setDescription("");  
             article1.setPicUrl("http://0.xiaoqrobot.duapp.com/images/avatar_liufeng.jpg");  
             article1.setUrl("http://blog.csdn.net/lyq8479/article/details/9141467");  

             Article article2 = new Article();  
             article2.setTitle("第8篇\n文本消息中使用网页超链接");  
             article2.setDescription("");  
             article2.setPicUrl("http://avatar.csdn.net/1/4/A/1_lyq8479.jpg");  
             article2.setUrl("http://blog.csdn.net/lyq8479/article/details/9157455");  

             Article article3 = new Article();  
             article3.setTitle("如果觉得文章对你有所帮助，请通过博客留言或关注微信公众帐号xiaoqrobot来支持柳峰！");  
             article3.setDescription("");  
             // 将图片置为空  
             article3.setPicUrl("");  
             article3.setUrl("http://blog.csdn.net/lyq8479");  

             articleList.add(article1);  
             articleList.add(article2);  
             articleList.add(article3);  
             newsMessage.setArticleCount(articleList.size());  
             newsMessage.setArticles(articleList);  
             return MessageUtil.MessageToXml(newsMessage);  
         }else{
        	 return null;
         }
	}
}
